<script setup>
import { RouterLink } from 'vue-router'
import { inject } from 'vue'

// 从App.vue中获取深色模式状态和切换函数
const { isDarkMode, toggleDarkMode } = inject('darkMode', { isDarkMode: false, toggleDarkMode: () => {} })
</script>

<template>
  <nav class="navbar">
    <div class="nav-container">
      <div class="nav-brand">
        <img src="/logo.png" alt="Logo" class="nav-logo" />
        <span class="brand-name">DGUT Video</span>
      </div>
      <div class="nav-links">
        <RouterLink to="/" class="nav-link">首页</RouterLink>
        <RouterLink to="/category" class="nav-link">分类</RouterLink>
        <RouterLink to="/all-video" class="nav-link">全部视频</RouterLink>
        <RouterLink to="/about" class="nav-link">点我</RouterLink>
      </div>
      <div class="nav-actions">
        <!-- <button class="search-btn">
          <i class="fas fa-search"></i>
          我是还没开发的搜索按钮
        </button> -->
        <button class="theme-toggle" @click="toggleDarkMode">
          <span v-if="isDarkMode">🌞</span>
          <span v-else>🌙</span>
        </button>
      </div>
    </div>
  </nav>
</template>

<style scoped>
.navbar {
  background: var(--card-bg);
  box-shadow: 0 2px 8px var(--card-shadow);
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  transition: all 0.3s ease;
}

.nav-container {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-logo {
  width: 40px;
  height: 40px;
}

.brand-name {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text-color);
  transition: color 0.3s ease;
}

.nav-links {
  flex: 2;
  display: flex;
  gap: 2rem;
  justify-content: center;
}

.nav-link {
  text-decoration: none;
  color: var(--text-color);
  opacity: 0.8;
  font-size: 1rem;
  transition: color 0.2s, opacity 0.2s;
}

.nav-link:hover,
.nav-link.router-link-active {
  color: #42b883;
  opacity: 1;
}

.nav-actions {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.search-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  background: var(--bg-color);
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.3s ease;
}

.search-btn:hover {
  background: var(--hover-shadow);
  color: #42b883;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--bg-color);
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.2rem;
}

.theme-toggle:hover {
  background: var(--hover-shadow);
  transform: rotate(15deg);
}
</style>